if exists (select * from sysobjects where id = object_id('hm_accounts') and objectproperty(id, 'isusertable') = 1) drop table hm_accounts ---
if exists (select * from sysobjects where id = object_id('hm_imapfolders') and objectproperty(id, 'isusertable') = 1) drop table hm_imapfolders ---
if exists (select * from sysobjects where id = object_id('hm_securityranges') and objectproperty(id, 'isusertable') = 1) drop table hm_securityranges ---
if exists (select * from sysobjects where id = object_id('hm_aliases') and objectproperty(id, 'isusertable') = 1) drop table hm_aliases ---
if exists (select * from sysobjects where id = object_id('hm_accounts') and objectproperty(id, 'isusertable') = 1) drop table hm_accounts ---
if exists (select * from sysobjects where id = object_id('hm_domains') and objectproperty(id, 'isusertable') = 1) drop table hm_domains ---
if exists (select * from sysobjects where id = object_id('hm_domain_aliases') and objectproperty(id, 'isusertable') = 1) drop table hm_domain_aliases ---
if exists (select * from sysobjects where id = object_id('hm_messages') and objectproperty(id, 'isusertable') = 1) drop table hm_messages ---
if exists (select * from sysobjects where id = object_id('hm_settings') and objectproperty(id, 'isusertable') = 1) drop table hm_settings ---
if exists (select * from sysobjects where id = object_id('hm_dbversion') and objectproperty(id, 'isusertable') = 1) drop table hm_dbversion ---
if exists (select * from sysobjects where id = object_id('hm_routes') and objectproperty(id, 'isusertable') = 1) drop table hm_routes ---
if exists (select * from sysobjects where id = object_id('hm_routeaddresses') and objectproperty(id, 'isusertable') = 1) drop table hm_routeaddresses ---
if exists (select * from sysobjects where id = object_id('hm_serverlog') and objectproperty(id, 'isusertable') = 1) drop table hm_serverlog ---
if exists (select * from sysobjects where id = object_id('hm_distributionlists') and objectproperty(id, 'isusertable') = 1) drop table hm_distributionlists ---
if exists (select * from sysobjects where id = object_id('hm_distributionlistsrecipients') and objectproperty(id, 'isusertable') = 1) drop table hm_distributionlistsrecipients ---
if exists (select * from sysobjects where id = object_id('hm_messagerecipients') and objectproperty(id, 'isusertable') = 1) drop table hm_messagerecipients ---
if exists (select * from sysobjects where id = object_id('hm_deliverylog') and objectproperty(id, 'isusertable') = 1) drop table hm_deliverylog ---
if exists (select * from sysobjects where id = object_id('hm_deliverylog_recipients') and objectproperty(id, 'isusertable') = 1) drop table hm_deliverylog_recipients ---
if exists (select * from sysobjects where id = object_id('hm_dnsbl') and objectproperty(id, 'isusertable') = 1) drop table hm_dnsbl ---
if exists (select * from sysobjects where id = object_id('hm_fetchaccounts') and objectproperty(id, 'isusertable') = 1) drop table hm_fetchaccounts ---
if exists (select * from sysobjects where id = object_id('hm_fetchaccounts_uids') and objectproperty(id, 'isusertable') = 1) drop table hm_fetchaccounts_uids ---
if exists (select * from sysobjects where id = object_id('hm_rules') and objectproperty(id, 'isusertable') = 1) drop table hm_rules ---
if exists (select * from sysobjects where id = object_id('hm_rule_criterias') and objectproperty(id, 'isusertable') = 1) drop table hm_rule_criterias ---
if exists (select * from sysobjects where id = object_id('hm_rule_actions') and objectproperty(id, 'isusertable') = 1) drop table hm_rule_actions ---
if exists (select * from sysobjects where id = object_id('hm_iphomes') and objectproperty(id, 'isusertable') = 1) drop table hm_iphomes ---
distributionlistaddress varchar(255) not null, CONSTRAINT u_distributionlistaddress UNIQUE NONCLUSTERED (distributionlistaddress),
distributionlistenabled tinyint not null,
distributionlistrequireauth tinyint not null,
distributionlistrequireaddress varchar(255) not null
) ---
CREATE CLUSTERED INDEX idx_hm_distributionlists_distributionlistdomainid ON hm_distributionlists (distributionlistdomainid) ---
create table hm_distributionlistsrecipients
(
distributionlistrecipientid int identity (1, 1) not null,
distributionlistrecipientlistid int not null,
distributionlistrecipientaddress varchar(255)
) ---
CREATE CLUSTERED INDEX idx_hm_distributionlistsrecipients_distributionlistrecipientlistid ON hm_distributionlistsrecipients (distributionlistrecipientlistid) ---
create table hm_messagerecipients
(
recipientid bigint identity (1, 1) not null,
recipientmessageid bigint not null,
recipientaddress varchar(255) not null,
recipientislocal tinyint not null,
recipientisenabled tinyint not null,
recipientisexisting tinyint not null,
recipientlocalaccountid int not null
) ---
CREATE CLUSTERED INDEX idx_hm_messagerecipients_recipientmessageid ON hm_messagerecipients (recipientmessageid) ---
create table hm_imapfolders
(
folderid int identity (1, 1) not null,
folderaccountid int NOT NULL,
folderparentid int NOT NULL,
foldername varchar(255) NOT NULL,
folderissubscribed tinyint NOT NULL
) ---
CREATE CLUSTERED INDEX idx_hm_imapfolders_folderaccountid ON hm_imapfolders (folderaccountid) ---
create table hm_securityranges
(
rangeid int identity (1, 1) not null,
rangepriorityid int not null,
rangelowerip bigint not null,
rangeupperip bigint not null,
rangeoptions int not null,
rangename varchar (100) not null, CONSTRAINT u_rangename UNIQUE NONCLUSTERED (rangename)